package com.uneed.widget;

import com.uneed.R;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public abstract class BasicAdapter extends BaseAdapter
{
  public static final Object ERROR;
  public static final Object HEAD;
  public static final Object LOADING = new Object();

  static
  {
    ERROR = new Object();
    HEAD = new Object();
  }

  protected View getFailedView(String paramString, View.OnClickListener paramOnClickListener, ViewGroup paramViewGroup, View paramView)
  {
    View localView1 = null;
    View localView2;
    localView1 = paramView;
      if ((paramView == null)||(paramView.getTag() != ERROR)) {
        localView1 = LayoutInflater.from(paramViewGroup.getContext()).inflate(R.layout.error_item, paramViewGroup, false);
        localView1.setTag(ERROR);
      }
      ((TextView)localView1.findViewById(android.R.id.text1)).setText(paramString);
      localView2 = localView1.findViewById(R.id.btn_retry);
      if (paramOnClickListener != null) {
          localView2.setVisibility(0);
          localView2.setOnClickListener(paramOnClickListener);
          localView2.requestFocus();
      } else {
          localView2.setVisibility(8);
      }

      return localView1;   	  
  }

  protected View getLoadingView(ViewGroup paramViewGroup, View paramView)
  {
    View localView = null;
    localView = paramView;
    if ((paramView == null)|| (paramView.getTag() != LOADING))
    {
    		localView = LayoutInflater.from(paramViewGroup.getContext()).inflate(R.layout.loading_item, paramViewGroup, false);
    		localView.setTag(LOADING);
    }
	return localView;
  }
}
